<?php if (!defined('THINK_PATH')) exit();?><!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<meta http-equiv="X-UA-Compatible" content="IE=edge">
		<title>广东国防教育学会</title>
		<meta name="viewport" content="initial-scale=1, maximum-scale=1">
		<meta name="apple-mobile-web-app-capable" content="yes">
		<meta name="apple-mobile-web-app-status-bar-style" content="black">
		<link rel="stylesheet" href="http://g.alicdn.com/msui/sm/0.6.2/css/sm.min.css" />
		<link rel="stylesheet" href="http://idangero.us/swiper/dist/css/swiper.min.css" />
		<link rel="stylesheet" href="/Public/Home/activity/css/style.css" />
	</head>
	<body>

<style>
.item-content.img_top{
	-webkit-box-align: inherit;
	-webkit-align-items: inherit;
	align-items: inherit;
}
.item-content.img_top .div_block{
	display: block;
    padding-top: 1rem;
}
</style>
		<div class="bar bar-nav">
			<h1 class="title">讨论列表 (<?php echo ($discuss_count); ?>)</h1>
			<i class="icon icon-left" onclick="window.history.go(-1);"></i>
		</div>
		<nav class="bar discuss_nav bar-tab">
				<input onclick="discuss_form('','')" readonly="readonly" type="text" placeholder="我要讨论.." />
		</nav>

		<div class="content">
			<div class="row discuss no-border" style="margin-top:0;">
				<div class="col-100">
					<div class="content-padded">
						<div class="list-block media-list" style="margin-top:0;">
							<ul id="discuss_ul">
							<?php if(is_array($discuss)): foreach($discuss as $k=>$discuss): ?><li class="item-content img_top">
									<div class="item-media div_block">
										<img src="<?php echo ($discuss['head_img']); ?>">
									</div>
									<div class="item-inner" onclick="discuss_form(<?php echo ($discuss['user_id']); ?>,'<?php echo ($discuss['nickname']); ?>')">
										<div class="item-title-row">
											<div class="item-title"><?php echo ($discuss['nickname']); ?><span class="pull-right"><?php echo (date("Y-m-d",$discuss['add_time'])); ?></span></div>
										</div>
										<?php if($discuss['reply_user_id']): ?><div class="item-title" style="line-height:20px;text-indent: 1em;color: #999;">回复&nbsp; <?php echo ($discuss['reply_nickname']); ?>：</div><?php endif; ?>
										<div class="item-subtitle"><?php echo ($discuss['content']); ?></div>
									</div>
								</li><?php endforeach; endif; ?>
							</ul>
						</div>
					</div>
				</div>
			</div>
			
			<div class="infinite-scroll-preloader" style="display:none;">
				<div class="preloader"></div>
			</div>
			<p onclick="ajax_sourch_submit();" id="load_more"><span class="icon icon-down"></span> 点击加载更多...</p>
			
			
			
			<div class="activity_from_bg discuss_1 discuss_close" style="display: none;"></div>
			<div class="activity_from discuss_from discuss_1" style="display: none;">
				
				<!-- <form action="" method="post" id="discuss_form"> -->
					<div class="list-block">
					<span id="form_query" class="discuss_from_btn discuss_close">确定</span>
					<span class="discuss_from_btn discuss_from_btn2 discuss_close">取消</span>
						<div class="item-title text-center">我要讨论</div>
				    <ul>
				      <!-- Text inputs -->
				      <li>
				        <div class="item-content">
				          <div class="item-inner">
				            <div class="item-input">
				            	<textarea name="content" class="js_discuss_bottom_text" placeholder="讨论.."></textarea>
				            </div>
				          </div>
				        </div>
				      </li>
				    </ul>
				  </div>
				  <div class="content-block">
				    <div class="row">
				    </div>
				  </div>
			   <!-- </form> -->
			</div>
</div>


		<script type="text/javascript" src="http://g.alicdn.com/sj/lib/jquery/dist/jquery.min.js"></script>
		<script type='text/javascript' src='http://g.alicdn.com/sj/lib/zepto/zepto.min.js' charset='utf-8'></script>
		<script type='text/javascript' src='http://g.alicdn.com/msui/sm/0.6.2/js/sm.min.js' charset='utf-8'></script>
		<script src="http://idangero.us/swiper/dist/js/swiper.min.js"></script>
		<script type="text/javascript" src="/Public/Home/activity/js/huodon.js" ></script>
		<script>
			
			var swiper = new Swiper('.swiper-container', {
				pagination: '.swiper-pagination',
				paginationClickable: true,
				loop:true,    
				grabCursor: true,
				autoplay: 3000
			});
			
			 /* $(document).on('click','.open-preloader', function () {
				 Zepto.showPreloader('加载中...')
				    setTimeout(function () {
				    	 Zepto.hidePreloader();
				    }, 2000); 
			 }); */
			 $(document).on('click','.open-indicator', function () {
				 Zepto.showIndicator();
			     setTimeout(function () {
			    	Zepto.hideIndicator();
			     }, 2000);
			  });
		</script>
		

	</body>

</html>

<script>
//Zepto.toast('操作成功，正在跳转...', 2000, 'success top');
var activity_id = <?php echo ($_GET['activity_id']); ?>;
var  page = 1;
 /*** ajax 提交表单 查询订单列表结果*/  
 function ajax_sourch_submit()
 {	 	 	 
	 	$(".infinite-scroll-preloader").show();
        page += 1;
		$.ajax({
			type : "GET",
			//url:"/index.php?m=Mobile&c=User&a=collect_list&is_ajax=1&p="+page,//+tab,			
			url:"/ActivityDetail/Discuss/activity_id/"+activity_id+"/is_ajax/1/p/"+page,// /activity_id/"+activity_id+"/is_ajax/1/p/"+page,//+tab,
//			data : $('#filter_form').serialize(),// 你的formid 搜索表单 序列化提交
			success: function(data)
			{
				$(".infinite-scroll-preloader").hide();
				if($.trim(data) == ''){
					$('#load_more').hide();
				}else{
				    $("#discuss_ul").append(data);
				}
			}
		}); 
 } 
</script>
<script>
var reply_user_id = '';
var reply_nickname = '';
function discuss_form(user_id, nickname){
	reply_user_id = user_id;
	reply_nickname = nickname;
	var text_placeholder = '';
	if(reply_nickname){
	    text_placeholder = '回复'+reply_nickname+'...';
	}else{
		text_placeholder = '讨论...'
	}
	$(".discuss_1").slideToggle();
	$("textarea[name='content']").attr('placeholder', text_placeholder);
}

$("#form_query").click(function(){
	var content = $("textarea[name='content']").val();
	if(content.length <= 0){
		Zepto.toast('请输入讨论内容', 2000, 'success top');
	}else if(content.length > 0 && content.length < 100){
		 $.ajax({
			type : "POST",
			//url:"/index.php?m=Mobile&c=User&a=collect_list&is_ajax=1&p="+page,//+tab,			
			url:"<?php echo U('ActivityDetail/addDiscuss');?>",//+tab,
			data : {'content':content, 'activity_id':activity_id,'reply_user_id':reply_user_id,'reply_nickname':reply_nickname},// 你的formid 搜索表单 序列化提交
			dataType : 'html',
			success: function(data){
				if(data != false){
					$("#discuss_ul").prepend(data);
					Zepto.toast('讨论成功', 2000, 'success top');
				}else{
					Zepto.toast('讨论失败!', 2000, 'success top');
				}
				$("textarea[name='content']").val('');
			}
		});  
	}
});
</script>